home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / write.h < prev   
Encoding:
C/C++ Source or Header  |  1994-10-10  |  2.2 KB  |  89 lines

  1. /*   Simple text editor. Text is represented as char**, every string is
  2.          \r\n - terminated.
  3. */
  4.  
  5. #ifndef __WRITE_H_
  6. #define __WRITE_H_
  7.  
  8. #include "window.h"
  9. #include "strtable.h"
  10.  
  11. #define STRINGS 250
  12. #define STRING_LEN 120
  13. #define BUFFER_SIZE 100 * STRING_LEN
  14.  
  15. enum { SAVED = 1, INS = 2 };
  16.  
  17. class Write : public Window
  18.     {
  19.     protected:
  20.         int mark_begin;  // Line number. We could mark only lines.
  21.         int mark_end;
  22.         int mark;
  23.         char* swapFile;
  24.     int status;
  25.         int total;       // Number of strings
  26.         char** buffer;
  27.         int line_num;    // Y position, absolute
  28.         loc curs;        // Pixels, on screen
  29.         int xTab;        // Text, on page
  30.         KH_STRTABLE* clip;
  31.     public:
  32.         Write(rect coordinates, char* swapName = "work.txt",
  33.            char* fName = "", char* h = "",
  34.            int s = 0, BORDERS b_type = SHOW_BORDER,
  35.            BORDERS hdr_b_type = SHOW_BORDER,
  36.            int pat = 0, int hdr_pat = 0);
  37.         virtual ~Write();
  38.  
  39.         char* getFileName() { return swapFile; }
  40.         void search();
  41.         void set_mark(int begin, int end)
  42.         { mark_begin = begin; mark_end = end; }
  43.         void set_swap(char* name)
  44.         {
  45.         delete swapFile;
  46.         swapFile = strdup(name);
  47.         }
  48.         void load_file();
  49.         void unload_file();
  50.         virtual void show();
  51.         virtual void hide();
  52.         void show_text(loc from);
  53.         int getLine(int num);                   // shift in buffer.
  54.         void outtext(int x, int y, char* txt);
  55.         int append(int line_num);
  56.         virtual void exe(int act = 0);
  57.         void swap();
  58.         void showCursor();
  59.         void hideCursor() { showCursor(); }
  60.         virtual void repose(rect r);
  61.  
  62.         int copy();
  63.         void cut();
  64.         void paste();
  65.  
  66.         void up(int sh);
  67.     void dn(int sh);
  68.     void left(int sh);
  69.     void right(int sh);
  70.     void home();
  71.     void end();
  72.     void pgUp();
  73.     void pgDn();
  74.     void toTop();
  75.     void toBottom();
  76.     void ctrl_y();
  77.     void del();
  78.     void bksp();
  79.     void processKey(uchar ch);
  80.     void setInsert()
  81.         {
  82.             int i = status & INS;
  83.         status = (status & SAVED) | (!i);
  84.         }
  85.  
  86.     };
  87.  
  88. #endif __WRITE_H_
  89.